package com.cardgame.model.buff;

import lombok.Getter;
import lombok.Setter;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
@Getter
@Setter
public class Buff {
    private Integer buffId;
    private String buffDescription; //Key->buffId, Value->buffDescription
    private EffectType buffEffectType;
    private Integer buffValue;
    private Integer buffDuration;

    public static Buff valueOf(Map<String, Object> buffMap) {
        Buff buff = new Buff();
        buff.setBuffId((Integer) buffMap.get("buffId"));
        buff.setBuffDescription((String) buffMap.get("buffDescription"));
        buff.setBuffEffectType(EffectType.valueOf((String) buffMap.get("buffEffect")));
        buff.setBuffValue(((Double) buffMap.get("buffEffects")).intValue());
        buff.setBuffDuration((Integer) buffMap.get("buffDuration"));
        return buff;
    }

    @Override
    public String toString() {
        return "Buff{" +
                "buffId=" + buffId +
                ", buffDescription='" + buffDescription + '\'' +
                ", buffEffect=" + buffEffectType +
                ", buffValue=" + buffValue +
                ", buffDuration=" + buffDuration +
                '}';
    }

    public Map<String, Object> toMap() {
        return Map.of(
                "buffId", buffId,
                "introduction", buffDescription,
                "buffEffect", buffEffectType,
                "buffValue", buffValue,
                "buffDuration", buffDuration
        );
    }
}
